<?php


namespace app\common\model;


class Banner extends BaseModel
{
    protected $name = 'store_banner';

    public function file()
    {
        return $this->belongsTo('UploadFile', 'image_id', 'file_id')
            ->bind(['file_path', 'file_name', 'file_url']);
    }

    public function getList($param=[]){

        return $this->with(['file'])->where($param)->order('id desc')->select();
    }


    public function add($images){
        $data = [
            'image_id' => $images,
            'wxapp_id' => self::$wxapp_id
        ];
        return $this->save($data);
    }

    public function setDelete($image_id)
    {
        return $this->where(['id'=>$image_id])->delete();
    }
}